package com.anolesoft.amljmes.system.param.mapper;

import com.anolesoft.amljmes.system.param.entity.MesParamConfigDO;
import org.apache.ibatis.annotations.*;

/**
 * @author zhj
 * @date 2022/1/7 10:45
 */
@Mapper
public interface MesParamConfigMapper {
    @Select("select objuid,param_name,param_value,modify_user,factory_id from mes_param_config where param_name=#{paramName,jdbcType=VARCHAR} and factory_id=#{factoryId,jdbcType=VARCHAR}")
    MesParamConfigDO selectOneByFactoryIdAndParamType(@Param("factoryId")String factoryId,@Param("paramName") String paramName);

    @Insert("insert into mes_param_config (objuid,param_name,param_value,modify_user,factory_id,modify_date) " +
            "values (" +
            "#{objuid,jdbcType=VARCHAR}," +
            "#{paramName,jdbcType=VARCHAR}," +
            "#{paramValue,jdbcType=VARCHAR}," +
            "#{modifyUser,jdbcType=VARCHAR}," +
            "#{factoryId,jdbcType=VARCHAR}," +
            "sysdate" +
            ")")
    int insert(MesParamConfigDO param);
    @Update("update mes_param_config set " +
            "param_name = #{paramName,jdbcType=VARCHAR}," +
            "param_value = #{paramValue,jdbcType=VARCHAR}," +
            "modify_user = #{modifyUser,jdbcType=VARCHAR}," +
            "modify_date = sysdate," +
            "factory_id = #{factoryId,jdbcType=VARCHAR} " +
            "where objuid = #{objuid,jdbcType=VARCHAR}")
    int update(MesParamConfigDO param);

}
